// ----------------------------------------
// Filename: Serial_Testing
// Description: the unit testing of the serial
// Author: Jon Maloney
// Date: 18-Jun-2012
//

//************************************************************
//                    Include .h files
//************************************************************

#include "Serial_Testing.h"
#include "serial.h"
#include "thread.h"
//************************************************************
//                    Include external references
//************************************************************

//************************************************************
//                    Define Statements
//************************************************************

//************************************************************
//                    Struct, Union, enum Statements
//************************************************************

//************************************************************
//                    Global variables and constants
//************************************************************

//************************************************************
//                    Prototype Private Functions
//************************************************************

void serialTest(void * pvParameters);

//************************************************************
//                    Implementation
//************************************************************

void Serial_Test(void)
{
	Thread_Create(serialTest, NULL, 200, 1);
}

void serialTest(void * pvParameters)
{
	UINT8 RxChar  	= 0;
	UINT8 testRX	= 'A';
	kernelTickType period = 200;
	xComPortHandle serialHandle = xSerialPortInitMinimal( 9600, 100 , sizeof(UINT8), sizeof(UINT8));
	
	for(;;)
	{
		//xSerialPutChar( serialHandle , (1+30), 1 );

		while(xSerialGet( serialHandle , &RxChar, 1 ) == pdTRUE )
		{
			xSerialPut( serialHandle , (void *)&testRX, 1 );
			xSerialPut( serialHandle , (void *)&RxChar, 1 );
		}
		
		Thread_Delay( period );
	}
}
